home *** CD-ROM | disk | FTP | other *** search
/ Champak 109 / Vol 109.iso / games / athlete_.swf / scripts / frame_2 / DoAction.as
Text File  |  2008-11-12  |  6KB  |  271 lines

  1. function setupplayers()
  2. {
  3.    players = new Array(maxplayers);
  4.    i = 0;
  5.    while(i < maxplayers)
  6.    {
  7.       players[i] = new player();
  8.       i++;
  9.    }
  10.    pl.duplicateMovieClip("pl0",200);
  11.    cpl.duplicateMovieClip("pl1",201);
  12.    pl0.gotoAndStop(p1type);
  13.    pl1.gotoAndStop(p2type);
  14.    pl0.body._rotation = 90;
  15.    players[0].ballsready.push(0);
  16.    players[0].leftk = 90;
  17.    players[0].rightk = 88;
  18.    players[0].firek = 83;
  19.    pl1.body._rotation = 90;
  20.    players[1].ballsready.push(1);
  21.    players[1].mx = 294;
  22.    players[1].my = 522;
  23. }
  24. function player()
  25. {
  26.    this.height = 10;
  27.    this.speed = 14;
  28.    this.leftk = 37;
  29.    this.rightk = 39;
  30.    this.firek = 38;
  31.    this.state = 0;
  32.    this.scale = 1;
  33.    this.loadspeed = 10;
  34.    this.firespeed = 5;
  35.    this.ballload = 0;
  36.    this.mx = 35;
  37.    this.my = 262;
  38.    this.ballsready = new Array();
  39.    this.ballsloaded = new Array();
  40.    this.cpuangle = 0;
  41. }
  42. function ballob()
  43. {
  44.    this.speed = 18;
  45.    this.xstep = 0;
  46.    this.ystep = 0;
  47.    this.gravity = 0.6;
  48.    this.state = 0;
  49.    this.type = 1;
  50.    this.hitby = 0;
  51. }
  52. function setupballs()
  53. {
  54.    balls = new Array(maxballs);
  55.    i = 0;
  56.    while(i < maxballs)
  57.    {
  58.       tbl = eval("ball" + i);
  59.       tbl.removeMovieClip();
  60.       testball.duplicateMovieClip("ball" + i,150 + i);
  61.       tbl = eval("ball" + i);
  62.       tbl.gotoAndStop(1);
  63.       balls[i] = new ballob();
  64.       i++;
  65.    }
  66. }
  67. function dropcreature(cno)
  68. {
  69.    tg = eval("ground" + cno + "" + (players[cno].height - 1));
  70.    tp = eval("pl" + cno);
  71.    while(tp._y + 20 * players[cno].scale < tg._y + (players[cno].scale - 0.8) * 5)
  72.    {
  73.       tp._y = tp._y + 1;
  74.    }
  75. }
  76. function fireball(pno)
  77. {
  78. }
  79. function removeboard()
  80. {
  81.    i = 0;
  82.    while(i < maxplayers)
  83.    {
  84.       j = 0;
  85.       while(j < players[i].height)
  86.       {
  87.          temp2 = eval("ground" + i + "" + j);
  88.          temp2.removeMovieClip();
  89.          j++;
  90.       }
  91.       i++;
  92.    }
  93. }
  94. function setupboard()
  95. {
  96.    i = 0;
  97.    while(i < maxplayers)
  98.    {
  99.       temp = eval("ground" + i);
  100.       temp._height = 160 / players[i].height;
  101.       j = 0;
  102.       while(j < players[i].height)
  103.       {
  104.          temp2 = eval("ground" + i + "" + j);
  105.          temp2.removeMovieClip();
  106.          temp.duplicateMovieClip("ground" + i + "" + j,i * players[i].height + j);
  107.          temp2 = eval("ground" + i + "" + j);
  108.          temp2._x = 147 + i * 267;
  109.          temp2._y = temp._y - (temp._height - 1);
  110.          temp2.gotoAndStop(j % 2 + 1);
  111.          temp = eval("ground" + i + "" + j);
  112.          j++;
  113.       }
  114.       cliff.swapDepths(100);
  115.       temp = eval("ground" + i);
  116.       temp._x = -300;
  117.       i++;
  118.    }
  119. }
  120. function setuptokens()
  121. {
  122.    i = 0;
  123.    while(i < maxtokensout)
  124.    {
  125.       ttoken = eval("token" + i);
  126.       ttoken.removeMovieClip();
  127.       token.duplicateMovieClip("token" + i,99);
  128.       ttoken = eval("token" + i);
  129.       ttoken._x = -100;
  130.       ttoken._y = -97;
  131.       ttoken.gotoAndStop(1);
  132.       i++;
  133.    }
  134. }
  135. function setballtype(bno, bt)
  136. {
  137.    btb = eval("ball" + bno);
  138.    btb.gotoAndStop(bt);
  139.    balls[bno].type = bt;
  140.    if(bt == 1)
  141.    {
  142.       balls[bno].gravity = 0.6;
  143.       balls[bno].speed = 18;
  144.    }
  145.    else if(bt == 2)
  146.    {
  147.       balls[bno].gravity = 0.1;
  148.       balls[bno].speed = 7;
  149.    }
  150.    else if(bt == 3)
  151.    {
  152.       balls[bno].gravity = 0.8;
  153.       balls[bno].speed = 22;
  154.    }
  155. }
  156. function placetoken()
  157. {
  158.    placing = 0;
  159.    if(tokensout < maxtokensout)
  160.    {
  161.       tt = Math.floor(Math.random() * 550);
  162.       if(1 >= tt)
  163.       {
  164.          if(ballsout < maxballs)
  165.          {
  166.             placing = 1;
  167.          }
  168.       }
  169.       else if(tt == 2)
  170.       {
  171.          ib = 0;
  172.          while(ib < ballsout)
  173.          {
  174.             if(balls[ib].type != 2)
  175.             {
  176.                if(placing == 100)
  177.                {
  178.                   placing = tt;
  179.                }
  180.                else
  181.                {
  182.                   placing = 100;
  183.                }
  184.             }
  185.             ib++;
  186.          }
  187.       }
  188.       else if(tt == 3)
  189.       {
  190.          ib = 0;
  191.          while(ib < ballsout)
  192.          {
  193.             if(balls[ib].type != 1)
  194.             {
  195.                placing = tt;
  196.             }
  197.             ib++;
  198.          }
  199.       }
  200.       else if(tt == 4)
  201.       {
  202.          ib = 0;
  203.          while(ib < ballsout)
  204.          {
  205.             if(balls[ib].type != 3)
  206.             {
  207.                placing = tt;
  208.             }
  209.             ib++;
  210.          }
  211.       }
  212.       else if(tt == 5)
  213.       {
  214.          ib = 0;
  215.          while(ib < maxplayers)
  216.          {
  217.             if(1.4 >= players[ib].scale)
  218.             {
  219.                placing = tt;
  220.             }
  221.             ib++;
  222.          }
  223.       }
  224.       else if(tt == 6)
  225.       {
  226.          ib = 0;
  227.          while(ib < maxplayers)
  228.          {
  229.             if(players[ib].scale >= 1)
  230.             {
  231.                placing = tt;
  232.             }
  233.             ib++;
  234.          }
  235.       }
  236.    }
  237.    if(0 < placing && placing < 50)
  238.    {
  239.       ttoken = eval("token" + tokensout);
  240.       tokensout++;
  241.       ttoken.gotoAndStop(placing + 1);
  242.       ttoken._x = 70 + Math.random() * 425;
  243.       ttoken._y = 15 + Math.random() * 66;
  244.    }
  245. }
  246. maxplayers = 2;
  247. maxballs = 6;
  248. humanplayers = 2;
  249. cpulevel = 15;
  250. ballsout = 2;
  251. mheight = 10;
  252. tokensout = 0;
  253. maxtokensout = 1;
  254. p1type = 1;
  255. p2type = 6;
  256. diflevel = 0;
  257. fireBall = new Sound();
  258. fireBall.attachSound("fireBall");
  259. levelGo = new Sound();
  260. levelGo.attachSound("levelGo");
  261. tokenPop = new Sound();
  262. tokenPop.attachSound("tokenPop");
  263. names = new Array();
  264. names[0] = "Joel";
  265. names[1] = "Carey";
  266. names[2] = "Tim";
  267. names[3] = "Steve";
  268. names[4] = "quiet phil";
  269. names[5] = "mortalbug";
  270. setupplayers();
  271.